package com.aacar.service.impl;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;

import com.aacar.dao.CheckCodeDao;
import com.aacar.entity.CheckCode;
import com.aacar.service.CheckCodeService;
import com.aacar.utils.DateUtil;

@Repository("checkCodeService")
public class CheckCodeServiceImpl implements CheckCodeService {
	
	private Log logger = LogFactory.getLog(CheckCodeServiceImpl.class);

	@Resource
	private CheckCodeDao checkCodeDao;
	
	@Override
	public CheckCode getCheckCode(CheckCode checkCode) {
		  checkCode.setStartTime(DateUtil.getToday().getTime());
		  checkCode.setEndTime(DateUtil.getTomorrow().getTime());
	      return checkCodeDao.findCheckCode(checkCode);
	}

	@Override
	public int saveCheckCode(CheckCode checkCode) {
		return checkCodeDao.save(checkCode);
	}

	@Override
	public int updateCheckCode(CheckCode checkCode) {
		checkCode.setModifyTime(DateUtil.getNowDate());
		return checkCodeDao.update(checkCode);
	}
}
